var Common = {
	//显示弹层
	showPop:function(exp){
        $(".mask-pop").show()
        $(exp).show();
    }
    //隐藏弹层
    ,hidePop:function(exp){
        $(exp).hide();
        $(".mask-pop").hide();
    }
    ,bindShowRule:function(){
        $(".rule-nav").bind("click",function(){
            Common.showPop(".rule-pop");
        });
        $(".rule-pop .close-btn").bind("click",function(){
            Common.hidePop(".rule-pop");
        })
    }
    ,bindSharePrompt:function(){
        $(".invite-btn").bind("click",function(){
            Common.showPop(".share-pop");
        });
    }
    ,bindShowReward:function(){
        $(".reward-nav").bind("click",function(){
            Common.showPop(".reward-pop");
        });
        $(".reward-pop .close-btn").bind("click",function(){
            Common.hidePop(".reward-pop");
        })
    }
};

var video = {

    _elTpl : '<div style="display:none;position:fixed;z-index:999999;' +
                 'left:0;right:0;top:0;bottom:0;' +
                 'background:rgba(0,0,0,0.75);">' +
               '<video src="" style="position:absolute;width:100%;' +
                   'left:0;right:0;top:50%;"></video>' +
             '</div>',

    _popEl    : null,
    _videoEl  : null,
    _videoCtl : null,

    open: function(url) {
        this._popEl.show();
        this._videoEl.attr('src', url);
        this._videoCtl.play();
        return this;
    },

    close: function() {
        this._videoCtl.pause();
        this._popEl.hide();
        this._videoEl.attr('src', '');
        return this;
    },

    init: function() {

        var that = this,
            height;

        this._popEl    = $(this._elTpl);
        this._videoEl  = this._popEl.find('video');
        this._videoCtl = this._videoEl[0];

        height = $(window).width() * 9 / 16;

        this._videoEl.css({
            height    : height,
            marginTop : height / -2
        });

        this._videoEl.bind('touchstart', function(e) {
            e.stopPropagation();
        });

        this._popEl.bind('touchstart', function() {
            that.close();
            return false;
        });

        $('body').append(this._popEl);

        return this;
    }
};